Repository navigation
Fixes #705: Handle renamed tag object type column in migration 0006 - #725
Conversation
…_tag_object_types to branches
|
@claude /review Only report on issues of potential concern; we don't need commentary on anything that doesn't require further consideration. |
|
Claude finished @arthanson's task in 3m 55s —— View job Review
Migration ( Index lookup inconsistency with
Unquoted identifiers in DDL statements ( cursor.execute(f"ALTER INDEX {schema_name}.{index.indexname} RENAME TO {result[0]}")
cursor.execute(f"ALTER TABLE {schema_table} RENAME COLUMN contenttype_id TO objecttype_id")
The table-existence check at the top of the loop uses an f-string rather than parameterized SQL, while the column-existence check below correctly uses Tests (
migration = loader.get_migration(*self.MIGRATION)If this test ever runs against a NetBox version that doesn't include loader = MigrationLoader(connection)
if self.MIGRATION not in loader.migrated_apps.get(self.MIGRATION[0], {}):
self.skipTest(f"{self.MIGRATION} not present in this NetBox version")
operation = next(op for op in migration.operations if op.model_name == 'tag' and op.name == 'object_types')If NetBox ever restructures
cursor.execute(f'SELECT COUNT(*) FROM "{schema}".{self.TABLE}')
branch_count = cursor.fetchone()[0]
cursor.execute(f'SELECT COUNT(*) FROM public.{self.TABLE}')
self.assertEqual(branch_count, cursor.fetchone()[0])This is correct but only verifies row count parity. If the migration were to silently truncate the copied table but still write the same number of rows, this would pass. A stronger assertion (e.g., |
|
Per Claude review:
|
Fixes: #705
Migration 0006 failed for open branches on installs that had already applied NetBox's
extras.0131. By then the column inextras_tag_object_typesis namedcontenttype_id, so the indexes copied into the branch schema no longer match the hard-coded names the migration tries to rename.This updates 0006 in place; no new migration is added.
objecttype_idorcontenttype_id); the target names are unchanged, since 0131 renames the column but not main's indexesobjecttype_idwhen the branch hasn't appliedextras.0131, so the branch's own migrate step can apply it latertest_upgrade.pyfor branches created before and after 0131, including applying 0131 afterward, checking that the copied indexes and rows match main